
var goods_table = require('../../../template/goodsTable/goods_table')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    goods: [],
    catid: '',
    msg: '',
    visible: true,
    lineOver: false,
    pageIndex: 0,
    pageSize: 10
  },
  LoadData: function() {
    var that = this;
    var catid=that.data.catid;
    var goods=goods_table.getGoods(catid);

    that.setData({
     goods:goods,
     lineOver:true,
     visible:false
    });
    if (that.data.goods.length == 0) {
      that.setData({
        msg: '还没有商品呢'
      });
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  GoGoodsDetail: function(e) {
    debugger;
    wx.navigateTo({
      url: '../detail/detail?id=' + e.currentTarget.dataset.id
    })
  },
  onLoad: function(options) {
    this.setData({
      catid: (options.catid == undefined ? '' : options.catid)
    });
    wx.setNavigationBarTitle({
      title: (options.title == undefined ? '商品列表' : options.title)
    });
    this.LoadData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

    return;
    if (this.data.lineOver)
      return;
    var that = this;
    that.setData({
      visible: true,
      pageIndex: that.data.pageIndex + 1
    });
    // this.nextLoading = this.selectComponent("#pageLoading");
    // this.nextLoading.ShowPageLoading();
    this.LoadData();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})